//
//  CellOfFind.m
//  PetAPP
//
//  Created by apple on 16/2/12.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "CellOfFind.h"
#import "ModelOfFind.h"
#import <YYWebImage.h>
#import <DKNightVersion.h>

@interface CellOfFind ()

@property (nonatomic, retain) UIImageView *imageViewOfIco;

@property (nonatomic, retain) UILabel *labelOfName;

@property (nonatomic, retain) UILabel *labelOfMembernum;

@property (nonatomic, retain) UIButton *buttonOfAdd;

@end

@implementation CellOfFind

- (void)dealloc {
    [_buttonOfAdd release];
    [_imageViewOfIco release];
    [_labelOfName release];
    [_labelOfMembernum release];
    [super dealloc];


}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self createSubViews];
        self.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:0.2952 green:0.2952 blue:0.2952 alpha:1.0]);
        
    }
    return self;
}

- (void)createSubViews {
    
    self.imageViewOfIco = [[UIImageView alloc]init];
    [self.contentView addSubview:_imageViewOfIco];
    [_imageViewOfIco release];
    
    
    self.labelOfName = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfName];
    [_labelOfName release];
    
    
    self.labelOfMembernum = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfMembernum];
    [_labelOfMembernum release];
    
    
    self.buttonOfAdd = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:self.buttonOfAdd];
    
    
    self.flag = YES;

}


- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.imageViewOfIco.frame = CGRectMake(15, 10, 50, 50);
    self.imageViewOfIco.layer.cornerRadius = 25;
    self.imageViewOfIco.layer.masksToBounds = YES;
    
    
    self.labelOfName.frame = CGRectMake(80, 10, 150, 25);
    self.labelOfName.font = [UIFont systemFontOfSize:23];
    
    self.labelOfMembernum.frame = CGRectMake(80, 40, 150, 20);
    self.labelOfMembernum.font = [UIFont systemFontOfSize:18];
    self.labelOfMembernum.textColor = [UIColor grayColor];
    
    self.buttonOfAdd.frame = CGRectMake(self.contentView.frame.size.width - 50, 20, 30, 30);
    [self.buttonOfAdd setImage:[UIImage imageNamed:@"add"] forState:UIControlStateNormal];
    if (self.flag == YES) {
        self.buttonOfAdd.hidden = NO;
    }else {
        self.buttonOfAdd.hidden = YES;
    }
    

}


- (void)handleDataWithModel:(ModelOfFind *)model {

//    self.imageViewOfIco.yy_imageURL = [NSURL URLWithString:model.ico];
    [self.imageViewOfIco yy_setImageWithURL:[NSURL URLWithString:model.ico] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];

    
    self.labelOfName.text = model.name;
    self.labelOfMembernum.text = model.membernum;

    
    

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
